<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<%@ page contentType="text/html; charset=utf-8"%>
	<%@ include file="/commons/taglibs.jsp"%>

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
		<title>我的申请列表</title>

		<%@ include file="/commons/css_js_head.jsp"%>


		<script type="text/javascript">
//复写Url
doListUrl = "${ctx }/base/typeAuditAction!doMyApply.ts";
doSaveUrl = "${ctx }/base/typeAuditAction!doSave.ts"
//添加之前
function doAddBefore(nid) {
	tb_show("update","${ctx }/base/userMachineTypeAction!doMyMachineAppTypeList.ts?nid=" + nid+"&keepThis=true&TB_iframe=true&width=600&height=490&modal=true",false);
}


//关闭小窗口
function onCancel()
{
	closeWindow();
}
function closeWindow()
{
	self.parent.tb_remove();
}

//更新之前 
function doUpdateBefore() {
	var nid="";
	var objs = document.getElementsByName("checkbox");
	for(var i=1; i<objs.length; i++) {
		if(objs[i].checked==true){
			nid=nid+(objs[i].value)+",";
			
		}	
	}	
	
	if(nid==""){
		alert("请选择要添加的应用类型");
		
		return false;
	}else{
	
		tb_show("update","${ctx }/base/userMachineTypeAction!doMyMachineTypeList.ts?nid=" + nid+"&keepThis=true&TB_iframe=true&width=600&height=490&modal=true",false);
	}
	
}

 //批量选择
 function checkAll(check,me){   
    // 首先获得所有checkbox集合  
    var names = document.getElementsByName(check); 
    
    var status=me.checked; 
    
    for(var i=0;i<names.length;i++){   
        if(status==true){           
		   names[i].checked=true;}
		else{
		    names[i].checked=false;
		}   
    }   
}  

//保存已选择信息终端类型ID
//选择要保存的应用的asid
function doSave(){


	if (doSaveUrl == '') {
		alert('请设置正确的URL!');
		return false;
	}
    var nid="";
	var objs = document.getElementsByName("checkbox");
	for(var i=0; i<objs.length; i++) {
		if(objs[i].checked==true){
			nid=nid+(objs[i].value)+",";
			
		}	
	}	
   
	if(nid==""){
	alert("请选择要添加的应用平台");
	return false;
	}else{
	$.ajax({
              type : "post",
              url : doSaveUrl ,
              cache: false,
              data : "machinesString=" + nid + "&idandusername="+'<%=request.getAttribute("idname")%>',
              dataType:"json",
              success : function(data){  
              //alert(data);
              if( data== "1" )
               {
                   alert("操作成功");
                   parent.window.location.reload();
                }
               else
               {
                   alert("操作失败");
                   parent.window.location.reload();
               }
              },
              error: function(){alert("服务器没有数据返回，可能服务器忙，请重试");}
           });
	
	}

	
}

//保存已选择信息终端类型ID
//选择要保存的应用的asid
function doSaveOne(nid){


	if (doSaveUrl == '') {
		alert('请设置正确的URL!');
		return false;
	}
    	
   
	if(nid==""){
	alert("请选择要添加的应用平台");
	return false;
	}else{
	$.ajax({
              type : "post",
              url : doSaveUrl ,
              cache: false,
              data : "machinesString=" + nid + "&idandusername="+'<%=request.getAttribute("idname")%>',
              dataType:"json",
              success : function(data){  
              //alert(data);
              if( data== "1" )
               {
                   alert("操作成功");
                   parent.window.location.reload();
                }
               else
               {
                   alert("操作失败");
                   parent.window.location.reload();
               }
              },
              error: function(){alert("服务器没有数据返回，可能服务器忙，请重试");}
           });
	
	}

	
}
</script>


	</head>
	<body style="overflow-x: hidden">

		<!-- 标题 -->
		<div class="mTitle">
			
			<b class="bbig">添加应用申请</b>
			
		</div>

		<!--list -->
		
		<div class="mainList">

			<table class="listTable">
				<tr>
				    <th><input type="checkbox" name="checkbox22" onclick="checkAll('checkbox',this)"/></th>
					<th>序号</th>
					<th>
						应用平台公司名称
					</th>
					<th>
						应用平台名称
					</th>
					<th>
						接口类型
					</th>
					<th>
						接口地址
					</th>
					<th>
						接口参数
					</th>
					
					<th>
						地址
					</th>
					
					<th>
						操作
					</th>
				</tr>

				<c:forEach var="appServer" varStatus="status" items="${pager.data}">
					<tr align=center>
						<td><input type="checkbox" name="checkbox" value="${appServer.asid }-${appServer.userName }" id="${appServer.asid }" /> </td>
						<td>${status.index+1} </td>
						<td>
						 ${appServer.dqM }
						</td>
						<td>
						
							${appServer.name}
						</td>
						<td>
							<c:if test="${appServer.interType == '0'}">  <span>Socket</span> </c:if>
						    <c:if test="${appServer.interType == '1'}">  <span>Webservice</span> </c:if>
						    <c:if test="${appServer.interType == '2'}">  <span>Http</span> </c:if>
						</td>
						<td>
							${appServer.interAddress }
						</td>
						<td>
							${appServer.interMethod }
						</td>
						
						
						<td>
							${appServer.address}
						</td>
						
						<td>
									<a href="javascript:void(0)"
										onclick="javascript:doSaveOne('${appServer.asid }-${appServer.userName }');"><span
										class="icon_edit">&nbsp;</span>接入</a>
								
									
						</td>
					</tr>
				</c:forEach>
			</table>
		</div>
		<!--end list -->
<a href="javascript:void(0)" onclick="javascript:doSave();"><span class="icon_add">&nbsp;</span>批量接入</a>
<div class="addToolbar">
				<p>
					
					<input class="btn" name="btn_return" value="返回" type="button"
						onclick="onCancel()" />
				</p>
			</div>

		<!-- 分页区域  -->
<%@ include file="/page/pager.jsp"%>

<script type="text/javascript">
ajaxAnywhere.formName = "form1";
ajaxAnywhere.getZonesToReload = function() {
    return "zoneList";
}
</script>

	</body>
</html>
